package com.example.design.c.state.demo2;

/**
 * 分数状态
 * 优秀
 */
public class HighState extends AbstractScoreState {

    public HighState(AbstractScoreState state) {
        this.setContext(state.getContext());
        this.setStateName("优秀");
        this.setTotalScore(state.getTotalScore());
    }

    @Override
    protected void checkState() {
        int totalScore = getTotalScore();

        ScoreContext context = getContext();
        if (totalScore < 60) {
            context.setScoreState(new LowState(this));
            return;
        }
        if (totalScore < 90) {
            context.setScoreState(new MiddleState(this));
        }
    }
}
